﻿using System;
using System.IO;

using Microsoft.VisualStudio.TestTools.UnitTesting;
using brevis.Nop.BusinessLogic.Reports;
using brevis.Nop.BusinessLogic.Data;
using brevis.Nop.SDK;
using brevis.Nop.SDK.Entity;
using System.Xml.Serialization;

namespace brevis.Nop.UnitTests
{
    [TestClass]
    public class brevisNopDataManagerTests
    {
        [TestMethod]
        public void TestNopReport_Get()
        {
            var nopReportId = "TEST";

            var nopReport = brevisNopDataManager.NopReport_Get(nopReportId);
            
            Assert.AreEqual(nopReportId, nopReport.Id);
                    
        }

        [TestMethod]
        public void TestNopReport_Set()
        {
            var nopReport = new NopReport();
            nopReport.Id = "4321";
            nopReport.Configuration = new NopReportConfiguration()
            {
                Check = new System.Collections.Generic.List<NopReportCheck>(),
                Parameter = new System.Collections.Generic.List<NopReportDataGetter>()

            };

            nopReport.Configuration.Check
                .Add(new NopReportCheck() { Type = "p-check type as string" });
            nopReport.Configuration.Check
                .Add(new NopReportCheck() { Type = "s-check type as string" });

            nopReport.Configuration.Parameter.Add(new NopReportDataGetter() 
            { 
                GetMethodAttribute = new System.Collections.Generic.List<MethodAttribute>() 
            });
            nopReport.Configuration.Parameter[0]
                .GetMethodAttribute.Add(new MethodAttribute 
                { 
                    Type = "System.String", Value = "orderguid" 
                });
            var ser = new XmlSerializer(typeof(NopReport));
            var fileStream = new FileStream("c:\\test.xml", FileMode.CreateNew);
            ser.Serialize(fileStream, nopReport);
            fileStream.Close();

            

        }
    }
}
